package InterfacePractice;

import java.util.Arrays;

public class Test {

    public static void main(String[] args) throws CloneNotSupportedException{

        Person person1=new Person("张三",12);
        Person person2=(Person)person1.clone();
        System.out.println("修改前"+person1.name+"  "+person1.age+"  "+person1.money.m);
        System.out.println("修改前"+person2.name+"  "+person2.age+"  "+person2.money.m);
        person1.money.m=99;
        System.out.println("修改后"+person1.name+"  "+person1.age+"  "+person1.money.m);
        System.out.println("修改后"+person2.name+"  "+person2.age+"  "+person2.money.m);

    }









    //多个进行比较
    public static void Mysort(Student[] students){
        for (int i = 0; i <students.length-1; i++) {
            for (int j = 0; j <students.length-1-i; j++) {
                if(students[j].compareTo(students[j+1])>0){
                    Student tmp=students[j];
                    students[j]=students[j+1];
                    students[j+1]=tmp;
                }
            }
        }

    }


    public static void main3(String[] args) {
        Student[] students=new Student[3];
        students[0]=new Student("abcd",8);
        students[1]=new Student("哈哈哈",22);
        students[2]=new Student("abc",10);
        System.out.println("排序前"+Arrays.toString(students));

//        Arrays.sort(students);
//        Mysort(students);
//        AgeComparator agecomparator=new AgeComparator();
//        Arrays.sort(students,agecomparator);

        NameComparator namecomparator=new NameComparator();
        Arrays.sort(students,namecomparator);
        System.out.println("排序后"+Arrays.toString(students));
    }

    public static void main1(String[] args) {
        //单个进行比较
        Student student1=new Student("abcd",11);
        Student student2=new Student("abcd",6);

        System.out.println(student1.compareTo(student2));

    }
}
